import { defineStore } from "pinia";
import { Subject } from "rxjs";

export interface SolverTask {
  taskId: string;
  taskName: string;
  isActive?: boolean;
}
export interface SolverTaskDetail {
  taskId: string;
  taskName: string;
  inputPath: string;
  outputPath: string;
  solver: string;
  cpu: number;
  memory: number;
  command: number;
  status: string;
}
export const useSolverStore = defineStore("solverStore", {
  state: () => ({
    // * 求解任务列表
    solverTaskList: [] as any[],
    // * 求解任务相关消息 - 发布订阅
    message: new Subject<any>(),
    // * 任务详情
    solverTaskDetail: {} as SolverTaskDetail,
    // * 任务详情弹窗是否激活
    taskDetailModalActive: false,
  }),
  actions: {
    // * 更新整个任务列表
    updateSolverTaskList(v: any[]) {
      this.solverTaskList = v;
    },
    // * 添加任务
    putSolverTaskList(v: any) {
      this.solverTaskList.push(v);
    },
    updateTaskDetailModalActive(v: boolean) {
      this.taskDetailModalActive = v;
    },
  },
});
